<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <base href="#(basePath)"/>
  <title>商户联系人-编辑</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="static/layui/css/layui.css" media="all">

	<script src="static/layui/layui.js"></script>
</head>
<body>
  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 20px 0 0;">
  	  <input type="hidden" name="contacts.id" value="#(contacts.id )">
  	  <div class="layui-form-item">
	    <label class="layui-form-label">账户别名</label>
	    <div class="layui-input-block">
      		<input type="text" name="contacts.alias" maxlength="30" value="#(contacts.alias )" required  lay-verify="required" placeholder="账户别名" autocomplete="off" class="layui-input">
    		</div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">账户类型</label>
	    <div class="layui-input-block">
			#if(contacts.accountType=='bankCard')
	      <input type="radio" name="contacts.accountType" value="bankCard" title="银行卡" #(contacts.accountType == 'bankCard' ? 'checked' : '')>
			#else
	      <input type="radio" name="contacts.accountType" value="wallet" title="钱包" #(contacts.accountType == 'wallet' ? 'checked' : '')>
			#end
	    </div>
      </div>
	  <div class="layui-form-item">
    		<label class="layui-form-label">钱包用户</label>
    		<div class="layui-input-block">
      		<select name="contacts.merchCode" lay-filter="merchCode" disabled="disabled">
       			<option value="">请选择</option>
       			#for(item : merchList)
      				<option value="#(item.code)" #(item.code== contacts.merchCode? 'selected' : '')>#(item.code)-#(item.name)</option>
      			#end
      		</select>
    		</div>
  	 </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label">账户户主</label>
	    <div class="layui-input-block">
      		<input type="text" name="contacts.accountName" maxlength="30" value="#(contacts.accountName )" required  lay-verify="required" placeholder="账户户主" autocomplete="off" class="layui-input">
    		</div>
	  </div>
  	  <div class="layui-form-item">
	    <label class="layui-form-label">账户号</label>
	    <div class="layui-input-block">
	      <input type="tel" name="contacts.accountNo" maxlength="30" value="#(contacts.accountNo )"  required  lay-verify="required" placeholder="账户号" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  #if(contacts.accountType == 'bankCard')
	  <div class="layui-form-item">
	    <label class="layui-form-label">公司/个人</label>
	    <div class="layui-input-block">
	      <input type="radio" name="contacts.isCompany" value="1" title="公司" #(contacts.isCompany == true ? 'checked' : '')>
	      <input type="radio" name="contacts.isCompany" value="0" title="个人" #(contacts.isCompany == false ? 'checked' : '')>
	    </div>
      </div>

	  <div class="layui-form-item">
		  <label class="layui-form-label">银行账户所属</label>
		  <div class="layui-input-block">
			  <input type="radio" name="contacts.isSelf" value="1" title="本人/本公司"  #(contacts.isSelf == true ? 'checked' : '' )>
			  <input type="radio" name="contacts.isSelf" value="0" title="他人/他公司" #(contacts.isSelf == false ? 'checked' : '' )>
		  </div>
	  </div>

      <div class="layui-form-item">
    		<label class="layui-form-label">银行名称</label>
    		<div class="layui-input-block">
      		<select name="contacts.bankEnglishLetters" lay-filter="bankEnglishLetters">
       			<option value="">请选择</option>
       			#for(item : topBankList)
      				<option value="#(item.shortEnName)" #(item.shortEnName == contacts.bankEnglishLetters ? 'selected' : '')>#(item.bankName)</option>
      			#end
      		</select>
    		</div>
  	 </div>
	 <div style="display: block" class="layui-form-item">
	    <label class="layui-form-label">开户行名</label>
	    <div class="layui-input-block">
	      <input type="text" name="contacts.openingBankName" maxlength="90" value="#(contacts.openingBankName )" required  lay-verify="required" placeholder="开户行名" autocomplete="off" class="layui-input">
	    </div>
	  </div>

	  <div style="display: none" class="layui-form-item">
	    <label class="layui-form-label">开户行号</label>
	    <div class="layui-input-block">
	      <input type="tel" name="contacts.openingBankNo" maxlength="30" value="#(contacts.openingBankNo )" placeholder="开户行号" autocomplete="off" class="layui-input">
	    </div>
	  </div>


	  <div class="layui-form-item" id="area-picker">
		  <label class="layui-form-label">省份/城市</label>
		  <div class="layui-input-block">
			  <div class="layui-input-inline">
				  <select name="contacts.province" class="province-selector" data-value="#(contacts.province)" lay-filter="province">
					  <option value="">请选择省</option>
				  </select>
			  </div>
			  <div class="layui-input-inline">
				  <select name="contacts.city" class="city-selector" data-value="#(contacts.city)" lay-filter="city">
					  <option value="">请选择市</option>
				  </select>
			  </div>
		  </div>
	  </div>



	  <div style="display: none" class="layui-form-item">
	    <label class="layui-form-label">身份证号</label>
	    <div class="layui-input-block">
	      <input type="text" name="contacts.certsNo" value="#(contacts.certsNo )" placeholder="身份证号" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  <div style="display: none" class="layui-form-item">
	    <label class="layui-form-label">手机号</label>
	    <div class="layui-input-block">
	      <input type="text" name="contacts.phoneNo" value="#(contacts.phoneNo )" placeholder="手机号" autocomplete="off" class="layui-input">
	    </div>
	  </div>
	  #end
	  <div class="layui-form-item">
	    <label class="layui-form-label">状态</label>
	    <div class="layui-input-block">
	      <input type="radio" name="contacts.isStop" value="1" title="禁用" #(contacts.isStop == true ? 'checked' : '')>
	      <input type="radio" name="contacts.isStop" value="0" title="启用" #(contacts.isStop == false ? 'checked' : '')>
	    </div>
      </div>
	  <div class="layui-form-item layui-hide">
	    <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
	  </div>
  </div>

  <script src="static/layui/layui.js"></script>
  <script>
  layui.config({
	base: '#(basePath)' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form', 'layarea'], function(){
    var $ = layui.$
    ,form = layui.form,layarea = layui.layarea;
    //监听提交
    form.on('submit(layuiadmin-app-form-edit)', function(data){
      var field = data.field; //获取提交的字段
      var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
      //提交 Ajax 成功后，关闭当前弹层并重载表格
      $.ajax({
    	  url: layui.setter.base+"admin/contacts/update",
    	  type:"post",
    	  data: field,
    	  success: function(res){
			  if(res.code !== 0){
				parent.layer.msg(res.msg, {icon: 2});
			  }else{
	    		  parent.layer.msg(res.msg, {icon: 1});
	    	      parent.layui.$("#LAY_app_body > div.layui-show iframe").get()[0].contentWindow.layui.table.reload('LAY-web-list'); //重载表格
	    	      parent.layer.close(index); //再执行关闭
			  }
    	  },
    	  error: function(xhr){parent.layer.msg("出错了" + xhr);}
      });
    });

      // 省市联动
      layarea.render({
          elem: '#area-picker',
          change: function (res) {
              console.log(res);
          }
      });
  })
  </script>
</body>
</html>
